<template>
	<view class="content">
		<view class="serch">
			<u--input placeholder="请输入科室关键字搜索" shape="circle" border="surround" clearable v-model="keyword"></u--input>
		</view>
		<!-- <view class="depart-con">
			<view class="depart-list" v-for="(item,index) in filteredPeople" :key="index" @click="goPage(item)">
				{{item.deptName}}
			</view>
		</view> -->
		<view class="mine-list">
			<view class="list-item" v-for="(item,index) in filteredPeople" :key="index" @click="goPage(item)">
				<view class="">{{item.deptName}}</view>
				<image src="../../static/img/jump.png" class="list-right-img"></image>
			</view>
		</view>
		<u-loading-page :loading="loading" loading-text="加载中..."></u-loading-page>
	</view>
</template>

<script>
	import {
		departmentApi
	} from "@/api/user"
	export default {
		data() {
			return {
				keyword: '',
				loading: true,
				time: '',
				dataList: [],
			}
		},
		onLoad(option) {
			this.time = option.time
			this.getList()
		},
		computed: {
			filteredPeople() {
				if (this.keyword === '') {
					return this.dataList;
				} else {
					return this.dataList.filter(person => person.deptName.includes(this.keyword)); // 根据输入内容过滤人员
				}
			}
		},
		methods: {
			async getList() {

				try {
					const res = await departmentApi({
						date: this.time
					})
					this.dataList = res.data
					this.loading = false
				} catch (e) {
					this.loading = false
				}

			},
			goPage(item) {
				uni.navigateTo({
					url: `/pages/bookdoctor/bookdoctor?time=${this.time}&deptNo=${item.deptNo}`
				})
			},
		}
	}
</script>

<style scoped>
	.content {
		width: 100vw;
		min-height: 100%;
		background: #F8F8F8;
		color: #666666;
		font-size: 27rpx;
		padding-top: 143rpx;
		padding-bottom: calc(23rpx + env(safe-area-inset-bottom));
		box-sizing: border-box;
	}

	.serch {
		position: fixed;
		top: 0;
		width: 100vw;
		background-color: #FFFFFF;
		height: 120rpx;
		padding: 0 31rpx;
		box-sizing: border-box;
		display: flex;
		align-items: center;
		justify-content: center;
		z-index: 9999;
	}

	.depart-con {
		margin-left: 31rpx;
		display: flex;
		flex-wrap: wrap;
	}

	.depart-list {
		width: 215rpx;
		height: 96rpx;
		background: #FFFFFF;
		border-radius: 10rpx;
		padding: 0 15rpx;
		box-sizing: border-box;
		margin-bottom: 23rpx;
		margin-right: 21rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		text-align: center;

	}

	.mine-list {

		background-color: #FFFFFF;
		padding: 0 31rpx;
	}

	.list-item {
		padding: 23rpx 0;
		box-sizing: border-box;
		display: flex;
		align-items: center;
		border-bottom: 1px solid #E7E7E7;
	}

	.mine-list .list-item:last-child {
		border: none;
	}

	.list-right-img {
		width: 31rpx;
		height: 31rpx;
		margin-left: auto;
	}
</style>